package ace.module.upms.sdk.core.feign.impl;

import ace.cmp.core.model.R;
import ace.cmp.openfeign.security.oauth2.core.config.FeignInternalServerOauth2SecurityConfig;
import ace.module.common.api.annotation.ApiRemoteProxyPriority;
import ace.module.upms.api.model.dto.UpmsApplicationDto;
import ace.module.upms.sdk.core.constant.SdkConstant;
import ace.module.upms.sdk.core.feign.UpmsApplicationFeignApi;
import io.swagger.v3.oas.annotations.Operation;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotEmpty;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * 权限应用 rpc feign.
 *
 * @author Caspar
 */
@FeignClient(
    name = "${spring.cloud.openfeign.client.config.upmsApplicationFeign.name:" + SdkConstant.FEIGN_SERVICE_NAME + "}",
    contextId = "upmsApplicationFeign",
    path = UpmsApplicationFeign.PATH,
    configuration = FeignInternalServerOauth2SecurityConfig.class,
    primary = false
)
@ApiRemoteProxyPriority
public interface UpmsApplicationFeign extends UpmsApplicationFeignApi {

  String PATH = "${spring.cloud.openfeign.client.config.upmsApplicationFeign.path:/upms/upms-application/rpc}";

  @Operation(summary = "获取权限应用")
  @GetMapping("/getByOutTypeAndOutId")
  R<UpmsApplicationDto> getByOutTypeAndOutId(
      @Valid @NotEmpty @RequestParam("outType") String outType,
      @Valid @NotEmpty @RequestParam("outId") String outId);

  @Operation(summary = "获取并检查权限应用")
  @GetMapping("/getAndCheckByOutTypeAndOutId")
  R<UpmsApplicationDto> getAndCheckByOutTypeAndOutId(
      @Valid @NotEmpty @RequestParam("outType") String outType,
      @Valid @NotEmpty @RequestParam("outId") String outId);

  @Operation(summary = "获取运营管理平台权限应用")
  @GetMapping("/getAdminApplication")
  R<UpmsApplicationDto> getAdminApplication();

  @Operation(summary = "获取运营管理平台权限应用,并且不能为null")
  @GetMapping("/getAndCheckNotNullAdminApplication")
  R<UpmsApplicationDto> getAndCheckNotNullAdminApplication();
}
